package com.prim.demo.t_spring_boot_mybatis.api;

import com.prim.demo.t_spring_boot_mybatis.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @Autowired
    private StuService stuService;

    @GetMapping("/getStu")
    public Object getStu(int id) {
        return stuService.getOne(id);
    }

    @PostMapping("/add")
    public Object addStu() {
        stuService.save();
        return "保存 ok";
    }

    @PostMapping("/update")
    public Object updateStu(int id) {
        stuService.update(id);
        return "更新 ok";
    }

    @PostMapping("/delete")
    public Object deleteStu(int id) {
        stuService.delete(id);
        return "删除 ok";
    }
}
